// Import at top level
import { initializeApp } from "firebase/app";
import { getAnalytics, logEvent } from "firebase/analytics";

let analytics;

if (process.client) {
  const firebaseConfig = {
    apiKey: "AIzaSyDc3FwOXV6TmPAxVuGHYCj8hXmLQkqmjM4",
    authDomain: "tt-web-1b0e6.firebaseapp.com",
    projectId: "tt-web-1b0e6",
    storageBucket: "tt-web-1b0e6.appspot.com",
    messagingSenderId: "832561284743",
    appId: "1:832561284743:web:10db3cbc3fd72fa0f11a22",
    measurementId: "G-SHD57DPK9M"
  };

  const app = initializeApp(firebaseConfig);
  analytics = getAnalytics(app);
  handleClick('guide_homepage_frist')
}

// Define handleClick at top level
export function handleClick(EventName, params) {
  //  console.log("click report", EventName, params);
  if (process.client) {
    // 上报点击事件
    logEvent(analytics, EventName, params);
  }
}